package com.core.ui.customtag;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

import com.core.protocols.IDescriptionViewDelegate;

public class DescriptionView
        extends TagSupport {

	/**
     * 
     */
	private static final long        serialVersionUID = 1L;
	private IDescriptionViewDelegate delegate         = null;



	public IDescriptionViewDelegate getDelegate () {

		return delegate;
	}



	public void setDelegate ( IDescriptionViewDelegate delegate ) {

		this.delegate = delegate;
	}



	@Override
	public int doStartTag ()
	        throws JspException {

		StringBuilder sb = new StringBuilder();

		sb.append("<div class=\"mod-content\">");
		sb.append("<p>");
		if ( delegate != null ) {
			String data = delegate.descriptionData();

			sb.append(data);

		}
		sb.append("</p>");
		sb.append("</div>");

		try {
			JspWriter writer = pageContext.getOut();
			writer.append(sb.toString());
		} catch ( IOException e ) {
			throw new JspException(e.getMessage());
		}

		return SKIP_BODY;
	}

}
